﻿#include "WoodBox.h"
#include "../DelayedAction.h"
#include "../MapObject.h"
#include "../../../Shared/Data/Stat.h"

using namespace Server::MirDatabase;
namespace S = ServerPackets;

namespace Server::MirObjects::Monsters
{

    bool WoodBox::getCanMove() const
    {
        return false;
    }

    WoodBox::WoodBox(MonsterInfo *info) : MonsterObject(info)
    {
    }

    void WoodBox::Attack()
    {
    }

    void WoodBox::Turn(MirDirection dir)
    {
    }

    bool WoodBox::Walk(MirDirection dir)
    {
        return false;
    }

    void WoodBox::ProcessRoam()
    {
    }

    void WoodBox::ProcessTarget()
    {
    }

    void WoodBox::Die()
    {
        DelayedAction tempVar(DelayedType::Die, getEnvir()->getTime() + 300);
        ActionList.push_back(&tempVar);
        MonsterObject::Die();
    }

    void WoodBox::CompleteDeath(std::vector<std::any> &data)
    {
        std::vector<MapObject*> targets = FindAllTargets(1, getCurrentLocation(), false);
        if (targets.empty())
        {
            return;
        }

        for (int i = 0; i < targets.size(); i++)
        {
            int damage = GetAttackPower(Stats[Stat::MinDC], Stats[Stat::MaxDC] * getEnvir()->Random->Next(1, 3));
            if (damage == 0)
            {
                return;
            }

            if (targets[i]->Attacked(this, damage, DefenceType::ACAgility) <= 0)
            {
                continue;
            }
        }
    }
}
